package com.sc.smartcommunity.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.smartcommunity.domain.Access;
import com.sc.smartcommunity.domain.OwnerComplaint;
import com.sc.smartcommunity.mapper.AccessMapper;
import com.sc.smartcommunity.service.AccessService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.LocalTime;


@Service
public class AccessServiceImpl extends ServiceImpl<AccessMapper, Access> implements AccessService {



    @Override
    public boolean saveAccess(Access access) {
       access.setStartTime(LocalTime.now());
       access.setEndTime(LocalTime.now());
        return save(access);
    }

    @Override
    public IPage<Access> getAccessRecordsByPage(int pageNum, int pageSize) {
        // Page<>(pageNum, pageSize)：pageNum=页码（从1开始），pageSize=每页条数
        Page<Access> page = new Page<>(pageNum, pageSize);
        // 分页查询：返回 IPage（包含总条数、总页数、当前页数据）
        return baseMapper.selectPage(page, null);
    }



}